<?php


namespace app\test\controller;


use app\service\cxyunService;
use think\App;
use think\Controller;

class Cxyun extends Controller
{

    public function test2(){
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->test();
        $str1 ="parkingId=5343054078414340259&timestamp=17034702340008CCE5873C0C98EE7C256BD4F1ACDEB58";
        $str  ="parkingId=5343054078414340259&timestamp=17034702340008CCE5873C0C98EE7C256BD4F1ACDEB58";
        echo strtoupper(md5($str));
    }

    public function test(){
        $data["parkingId"]="5343054078414340259";
        $data["empName"]="";
        $data["empMoblie"]="";
        $data["plateNumber"]="";
        $data["carTypeId"]="";//carTypeId车类ID
        $data["carModelId"]="";//carModelId车型ID
        $data["startTime"]="";
        $data["endTime"]="";
        $data["timestamp"]=time();

        $cxyunApi=new cxyunService();
        $res=$cxyunApi->getParkCarType($data["parkingId"]);
        echo "<pre>";
        var_dump(json_decode($res,true));
        echo "cxyun";
    }

    public function getParkCarType(){
        $data["parkingId"]="5369467354105601639";
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->getParkCarType($data["parkingId"]);
        $result= json_decode($res,true);
        $result= json_decode($result["Data"],true);
        echo "<pre>";
        var_dump($result);
    }
    public function getParkCarModel(){
        $data["parkingId"]="5369467354105601639";
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->getParkCarModel($data["parkingId"]);
        echo "<pre>";
        var_dump(json_decode($res,true));
    }

    //新增月租车
    public function saveMonthlyRent(){
        $data["parkingId"]="5369467354105601639";
        $data["empName"]="杨战磊";
        $data["empMoblie"]="18856151031";
        $data["plateNumber"]="皖LXH902";
        $data["carTypeId"]="4764425574344280680";//carTypeId车类ID
        $data["carModelId"]="5165925130768704771";//carModelId车型ID
        $data["startTime"]="2023-12-26 00:00:00";
        $data["endTime"]="2024-12-26 00:00:00";
        $data["timestamp"]=time()."000";
        $notData["gateId"]="";
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("saveMonthlyRent",$data,$notData);
//        $result= json_decode($res,true);
//        $res=$cxyunApi->saveMonthlyRent($data);
        echo "<pre>";
        var_dump(json_decode($res,true));
    }


    //getMonthlyRent月租车信息
    public function getMonthlyRent(){
        $data["parkingId"]="5343054078414340259";
        $data["plateNumber"]="皖LXH901";
        $data["timestamp"]=time()."000";

        $cxyunApi=new cxyunService();
        $res=$cxyunApi->getMonthlyRent($data);
        echo "<pre>";
        var_dump(json_decode($res,true));
    }

    //月卡续费
    public function payMonthly(){
        $data["parkingId"]="5369467354105601639";
        $data["plateNumber"]="皖LXH902";
        $data["amount"]="300";
        $data["payType"]=1;
        $data["startTime"]="2023-12-26 01:00:00";
        $data["endTime"]="2025-12-26 24:00:00";


        $data["timestamp"]=time()."000";
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->payMonthly($data);
        echo "<pre>";
        var_dump(json_decode($res,true));
    }
    //用于根据车场ID获取所有月卡车
    public function getMonthlyRentList(){
        $data["parkingId"]="5343054078414340259";
        $data["parkingId"]="5369467354105601639";
        //$data["plateNumber"]="皖LXH901";
        $data["timestamp"]=time()."000";
        $data["pageIndex"]=1;
        $data["pageSize"]=50;
        $notData["plateNumber"]="";//皖LXH901
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("getMonthlyRentList",$data,$notData);
        $result= json_decode($res,true);
        //$result= json_decode($result["Data"],true);
         echo "<pre>";
         var_dump($result);
        //var_dump(json_decode($res,true));
        //var_dump(json_decode($result,true));
    }
    
    //删除月租车
    public function delMonthlyRent(){
        $data["parkingId"]="5369467354105601639";
        $data["plateNumber"]="皖LXH902";
        $data["timestamp"]=time()."000";
        $notData=array();
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("delMonthlyRent",$data,$notData);
        echo "<pre>";
        var_dump(json_decode($res,true));
        
    }
    
    //
    public function calculatingTempCost(){
        $data["parkingId"]="5343054078414340259";
        $data["parkingId"]="5369467354105601639";
        $data["plateNumber"]="皖LXH901";
        $data["timestamp"]=time()."000";
        $notData=array();
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("calculatingTempCost",$data,$notData);
        $result= json_decode($res,true);
        echo "<pre>";
        var_dump($result);return;
        $result= json_decode($result["Data"],true);
        echo "<pre>";
        var_dump($result);
        $this->payTempCost($result);
    }

    public function payTempCost($params){
        $data["parkingId"]="5369467354105601639";
        $data["plateNumber"]="浙A123333";
        $data["timestamp"]=time()."000";
        $data["orderNo"]=$params["orderNo"];
        $data["payFee"]=$params["payFee"];
        $data["payType"]=3;
        $data["orderId"]=$params["orderNo"];//$params["orderId"];
        $notData=array();
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("payTempCost",$data,$notData);
        $result= json_decode($res,true);
        echo "<pre>";
        var_dump($result);
    }

    public function getParkGate(){
        $data["parkingId"]="5369467354105601639";
        $data["timestamp"]=time()."000";
        $notData=array();
        $cxyunApi=new cxyunService();
        $res=$cxyunApi->commonPost("getParkGate",$data,$notData);
        $result= json_decode($res,true);
        $result= json_decode($result["Data"],true);
        echo "<pre>";
        var_dump($result);
    }
}